﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Coolite.Ext.Web;
using GMAO.CORE;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        log4net.ILog log = log4net.LogManager.GetLogger("GMAO");
        log.Info("1");
        Session.Clear();
        txtUsername.FieldLabel = Resources.GMAO.Login;
        txtPassword.FieldLabel = Resources.GMAO.MDP;
    }

    protected void BtLogin_Click(object sender, AjaxEventArgs e)
    {
        log4net.ILog log = log4net.LogManager.GetLogger("GMAO");
        log.Info("2");
        if (GMAO_USER.AuthenticateUser(txtUsername.Text.Trim(), txtPassword.Text.Trim()))
        {
            GMAO_USER CurrentUser = new GMAO_USER();
            CurrentUser.Login = txtUsername.Text.Trim();
            CurrentUser.LoadUserByLOGIN();
            Session["IDUtilisateur"] = CurrentUser.ID;
            Response.Redirect("Default.aspx");
        }
        else
        {
            this.SMLogin.AddScript("alert('Le login ou le mot de passe semble etre incorrect');");
        }
    }
}
